<?php

require_once 'config/config.php';
/**********************************************************************
 * section r�serv� � d'�ventuels traitements ou r�cup�ration de donn�es 
 **********************************************************************/



// traitement de l'ajout d'un computer
if(isset($_POST['validation']))
{
	
	$comp = $_POST['name'];
	$key_comp = $_POST['ckey'];
	$email = $_POST['email'];
	$receive_notice = (isset($_POST['notice']))?1:0;
	
	if($comp!="" && $key_comp!="" && $email!="")
	{
		$sql = "
			SELECT * FROM spy_computer
			WHERE computer='".$comp."'
			AND fid_account=$id_user
		";
		$query = mysql_query($sql);
		if(mysql_num_rows($query)>0)
		{
			$msg = "Cet ordinateur existe d&eacute;j&agrave; !";
		}
		else
		{
			
			$sql = "
					INSERT INTO spy_computer
					(fid_account,computer,key_comp,mail_comp,receive_notice)
					VALUES
					($id_user,'".$comp."','".$key_comp."','".$email."','".$receive_notice."')
			";
			mysql_query($sql);
			header("Location:computers.php");
		}
	}
	
}



// traitement de la suppression d'un utilisateur
if(isset($_GET['delcomp']))
{
	$sql = "DELETE FROM spy_computer WHERE id_comp='".$_GET['delcomp']."' and fid_account=$id_user";
	mysql_query($sql);
	header("Location:computers.php");
}



$sql = "
		SELECT * FROM spy_computer WHERE fid_account=$id_user
";
$dataUser = mysql_query($sql);



/**********************************************************************
 * fin de section traitement
 *********************************************************************/


// affichage du template associ� � la page
include "tpl/".$_CONFIG['tpl']."compadm.php";